<?php namespace web\admin\controller;
/** .-------------------------------------------------------------------
 * |  Software: [HDPHP framework]
 * |      Site: www.hdphp.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

class Webset extends Common {
	private $db;
	public function __construct(){
		parent::__construct();
		$this->db=new \system\model\Webset;
	}
	//首页
	public function index() {
		if(IS_POST){
//			var_dump($_POST);die;
			foreach ($_POST as $k=>$v){
				$this->db->where('name',$k)->update(array('value'=>$v));
			}
						
//		写入配置项	
//		将获取的post数据转字符串
			$data=var_export($_POST,true);
//		将字符串写入配置项			
			file_put_contents('system/config/webset.php', "<?php \r\n return ".$data."?>");
//			提示
			message('写入成功',U('index'));
		}

//		获取数据
		$data=$this->db->get();
//		var_dump($data);die;
//		分配数据到页面
		View::with('data',$data);

		View::make();
	}

}